package cn.wolfcode.luowowo.common.util;

import java.security.MessageDigest;

public class MD5
{
  public static String encoder(String msg)
  {
    MessageDigest digest;
    try
    {
      digest = MessageDigest.getInstance("md5");
      StringBuilder sb = new StringBuilder(40);
      byte[] data = digest.digest(msg.getBytes("UTF-8"));
      byte[] arrayOfByte1 = data; int i = arrayOfByte1.length; for (int j = 0; j < i; ++j) { byte b = arrayOfByte1[j];
        int temp = b & 0xFF;
        if ((temp < 16) && (temp >= 0))
          sb.append("0").append(Integer.toHexString(temp));
        else
          sb.append(Integer.toHexString(temp));
      }

      return sb.toString();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}